package com.llseven.ai.spring.llseven.config;


import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author ywb
 * @date 2023-02-22 18:37
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    
    /**
     * 跨域 cors 配置
     */
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
            .allowedOriginPatterns("*") // 使用 allowedOriginPatterns 替代 allowedOrigins
//            .allowedOrigins("*")
            .allowCredentials(true)
            .allowedMethods("GET", "POST", "PUT", "DELETE");
    }
    
}

